/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package loginapp;

import javax.swing.ButtonModel;
import javax.swing.DefaultButtonModel;
import javax.swing.JOptionPane;

/**
 *
 * @author Leonardo Fernandes
 */
public class FrmAula02Swing extends javax.swing.JFrame {

    /**
     * Creates new form FrmCadastroConta
     */
    public FrmAula02Swing() {
        initComponents();
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        rdbSamba = new javax.swing.JRadioButton();
        rdbRock = new javax.swing.JRadioButton();
        rdbSertanejo = new javax.swing.JRadioButton();
        cmbIdade = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        lblResposta = new javax.swing.JLabel();
        btnSalvar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Cadastro Conta");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Preferência Musical"));

        buttonGroup1.add(rdbSamba);
        rdbSamba.setSelected(true);
        rdbSamba.setText("Samba");
        rdbSamba.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbSambaActionPerformed(evt);
            }
        });

        buttonGroup1.add(rdbRock);
        rdbRock.setText("Rock");
        rdbRock.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbRockActionPerformed(evt);
            }
        });

        buttonGroup1.add(rdbSertanejo);
        rdbSertanejo.setText("Sertanejo");
        rdbSertanejo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbSertanejoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rdbSamba)
                    .addComponent(rdbRock)
                    .addComponent(rdbSertanejo))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdbSamba)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rdbRock)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rdbSertanejo)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        cmbIdade.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Até 10 anos", "Entre 11 e 15 anos", "Entre 16 e 23 anos", "Acima de 23 anos" }));
        cmbIdade.setSelectedIndex(1);
        cmbIdade.setToolTipText("Escolha a sua sua idade.");
        cmbIdade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbIdadeActionPerformed(evt);
            }
        });

        jLabel1.setText("Faixa de Idade: ");

        lblResposta.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        btnSalvar.setText("Salvar");
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblResposta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cmbIdade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addComponent(btnSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbIdade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblResposta, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
                .addComponent(btnSalvar)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void rdbSambaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbSambaActionPerformed
        lblResposta.setText("Você ainda tem solução...");
    }//GEN-LAST:event_rdbSambaActionPerformed

    private void rdbRockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbRockActionPerformed
        lblResposta.setText("Isso sim é gosto musical...");
        
        String[] conj = {"Charlie Brown", "Paralamas", "Titãs"};        
        
        cmbIdade.addItem("Arapiraca");
        cmbIdade.addItem(conj[1]);
        cmbIdade.addItem(conj[2]);
    }//GEN-LAST:event_rdbRockActionPerformed

    private void rdbSertanejoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbSertanejoActionPerformed
        lblResposta.setText("Desista, você perdeu o senso de gosto musical...");        
 
        //cmbIdade.removeAllItems();
        cmbIdade.removeAllItems();
    }//GEN-LAST:event_rdbSertanejoActionPerformed

    private void cmbIdadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbIdadeActionPerformed

        
        int i = cmbIdade.getSelectedIndex();        
        switch (i){
            case 0:
                lblResposta.setText("Opção 0");                
                break;
            case 1:    
                lblResposta.setText("Opção 1");
                break;
            case 2:
                lblResposta.setText("Opção 2");
                break;
            case 3:    
                lblResposta.setText("Opção 3");
                break;
            default:
                lblResposta.setText("Sem opção");
                break;
        }
        
        
    }//GEN-LAST:event_cmbIdadeActionPerformed

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
 
        if(rdbSamba.isSelected() == true){
            lblResposta.setText("Samba");
        } else if(rdbRock.isSelected() == true){
            lblResposta.setText("Rock");
        } else {
            lblResposta.setText("Sertanejo");
        }
    }//GEN-LAST:event_btnSalvarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmAula02Swing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmAula02Swing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmAula02Swing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmAula02Swing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrmAula02Swing().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSalvar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cmbIdade;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblResposta;
    private javax.swing.JRadioButton rdbRock;
    private javax.swing.JRadioButton rdbSamba;
    private javax.swing.JRadioButton rdbSertanejo;
    // End of variables declaration//GEN-END:variables
}
